<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0">
  <title>Test!</title>
  <style>
    body{
      margin:0;
      padding:0;
    }
    canvas {
      background:#56bc8a;
      display:block;
      width:calc(100%);
      height:calc(100vh);
    }
  </style>
  <script src="https://upcdn.b0.upaiyun.com/libs/jquery/jquery-2.0.2.min.js"></script>

</head>
<body>
  
  <canvas id="myShape"></canvas>
  <button style="position:fixed; bottom:10%; left:50%">打印一个</button>



  <!-- 粒子特效文件 -->
  <script src="shape-shifter.js"></script>
  <!-- 逻辑 -->
  <script>
      let shapeShifter = S;
      
      //data：获奖名单，len：名单长度，i：当前播放位置
      let data={}, len = 0, i=0;

      window.onload=function(){
          //shapeShifter.init(document.getElementById('myShape'),'任意内容');
          //初始化
          shapeShifter.init(document.getElementById('myShape'), 'Shape|Shifter|Timer|will start|#countdown 6||');
          
          //获取获奖名单
          $.getJSON("data.json", function(json) {
            console.log(json.data[1].id);
            data = json.data;
            len = data.length;
            console.log(data, '\n'+len+'\n');
          });
      }

      $("button").click(
        function () {
          if(i<len){
            //播放姓名
            shapeShifter.UI.simulate(data[i].id+"");
            console.log(data[i].name);//这句没用可以删
            i++;
          }else{
            //避免越界
            shapeShifter.UI.simulate("Too Many");
          }
          
        }
      )

  </script>

</body>
</html>
